<?php
namespace API\Controller;
use Think\Controller;
class HomeUserController extends CommonController {
	
	public function isLogin(){
		if (!isset($_SESSION['USERID']) || $_SESSION['USERID']=='' ) {
			$this->response("判断商城用户登录状态",false,0,"请先登录再进行操作！");
		}else{
			$this->response("判断商城用户登录状态",true,1,$_SESSION['USERID']);
		}
	}
	//载入展示所有商品分类
	public function loadGoodsul(){
		$Sort = M("Sort");
		$Sortdata = $Sort->order("id ASC")->select();
		if (empty($Sortdata)) {
			$this->response("载入商品一级分类信息",false,0,"商品一级分类信息为空！");
		}else{
			$TwoSort = M("Twosort");
			$Goods = M("Goods");
			$sortlist = array();
			foreach ($Sortdata as  $val) {
				//商品一级分类图标解码
				$val['sortimgurl']  = json_decode($val['sortimgurl'],true);
				//查找商品二级分类信息
				$Twosortdata = $TwoSort->where("sortid = {$val['id']}")->select();
				
				$val['twosortdata'] = $Twosortdata;
				foreach ($Twosortdata as $key=>$value){
					//商品二级分类图标解码
					$val['twosortdata'][$key]['twosortimgurl'] = json_decode($value['twosortimgurl'],true);
					//查找对应二级分类下的商品信息
					$Goodsdata = $Goods->where("twosortid = {$value['id']} ")->limit(3)->select();
					$val['twosortdata'][$key]['goodsdata'] = $Goodsdata;
				}
				$sortlist[ ] = $val;
			}
			$this->response("载入商品信息ul",true,1,$sortlist);
		}
	}

	
}